
function CarrotGroup() {

	this.move = 0;
	this.dx = 0;
	this.dx = 0;

	var img;
}

CarrotGroup.prototype.setCarrots = function(amount,y1, position, layer, images) {
	var carrots = new Array();

	for ( var k = 0; k < amount; k++) {

		this.img = new Kinetic.Image({
			image : images["carrot"],
			x : position,
			y : y1,
			
			rotation : 2 * Math.PI * k / 5
		});
	
		layer.add(this.img);
		carrots[k] = this.img;
	}

	var center = new Kinetic.Circle({
		x : position,
		y : y1,
		radius : 20

	});

	center.on('mouseover', function() {

		this.setFill('orange');
		layer.draw();
		document.body.style.cursor = 'pointer';
		center.moveToTop();
	});
	center.on('mouseout', function() {

		this.setFill('');
		layer.draw();
		document.body.style.cursor = 'auto';
		//center.moveToTop();
	});

	center.on('click', function() {
		
		center.setRadius(0);
		this.setFill('orange');
		layer.draw();
		document.body.style.cursor = 'pointer';
		layer.moveToTop();

		anim.start();
	});
	
	var move=0;
	var anim = new Kinetic.Animation(
			{
				
				func : function(frame) {
					
					
					if(carrots[move].getY()<100){
						carrots[move].setRotation(0);
						move++;
						
					}
					if(move>amount-1){
						console.log("slut");
						this.stop();
						CheckResult(amount);
						return;
						
					}
					carrots[move].setX(carrots[move].getX()-1*((amount-move-1)));
					carrots[move].setY(carrots[move].getY()-3);
					
				},
				node : layer
			});

	layer.add(center);

};


